<?php

use Illuminate\Support\Facades\URL;
use Cartalyst\Sentry\Facades\Laravel\Sentry as Sentry;

$clang = Config::get('application.language', 'en');
$flags = Config::get('probackend::config.sites.flags');
$languages = Config::get('probackend::config.sites.languages');
$logo = Config::get('probackend::config.sites.logo');
$logoText = Config::get('probackend::config.sites.logo-text');

$user = Sentry::getUser();
$avatar = $user->avatar == null ? Config::get('probackend::config.sites.avatar-default') : $user->avatar;
$username = $user->first_name . ' ' . $user->last_name;
?>

<div class="navbar navbar-inverse" role="navigation">
    <div class="navbar-header">
        <a class="navbar-brand" href="#">
            <img src="{{$logo}}" alt="{{$logoText}}">
        </a>
        <a class="sidebar-toggle">
            <i class="icon-paragraph-justify2"></i>
        </a>            
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-icons"><span class="sr-only">Toggle navbar</span><i class="icon-grid3"></i></button>
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar"><span class="sr-only">Toggle navigation</span><i class="icon-paragraph-justify2"></i></button>
    </div>
    <ul class="nav navbar-nav navbar-right collapse" id="navbar-icons">
        <li class="language dropdown"><a class="dropdown-toggle" data-toggle="dropdown">
                <img src="{{$flags[$clang]}}"><span>{{$languages[$clang]}}</span><i class="caret"></i></a>
            <ul class="dropdown-menu dropdown-menu-right icons-right" style="display: none;">
                @foreach($languages as $lang => $title)
                <?php if($lang==$clang) continue;?>
                <li><a href="{{URL::route($prefix . '.language',["lang"=>$lang])}}"><img src="{{$flags[$lang]}}"/>{{$title}}</a></li>
                @endforeach
            </ul>
        </li>
        <li class="user dropdown"><a class="dropdown-toggle" data-toggle="dropdown"><img src="{{$avatar}}"><span>{{$username}}</span><i class="caret"></i></a>
            <ul class="dropdown-menu dropdown-menu-right icons-right" style="display: none;">
                <li><a onclick="alert('Comming Soon')" href="#"><i class="icon-cog"></i>{{translate("probackend::global.menu_settings")}}</a></li>
                <li><a href="{{URL::route($prefix.".logout")}}"><i class="icon-exit"></i>{{translate("probackend::global.menu_logout")}}</a></li>
            </ul>
        </li>
    </ul>
</div>
